#include "NArcUtil.hpp"
#include "NZipArchive.hpp"
#include "NRarArchive.hpp"

DLL_API NArcUtil::NArcUtil(void)
{
}

DLL_API NArcUtil::~NArcUtil(void)
{
}

NArchive* NArcUtil::arcfactory( const char* filename, bool open /*= false*/ )
{
    NZipArchive zip;
    if (zip.issupport(filename))
    {
        return new NZipArchive(filename);
    }
    NRarArchive rar;
    if (rar.issupport(filename))
    {
        return new NRarArchive(filename);
    }
    return NULL;
}

DLL_API NArchive* NArcUtil::arcfactory( const wchar_t* filename, bool open /*= false*/ )
{
    NZipArchive zip;
    if (zip.issupport(filename))
    {
        return open? new NZipArchive(filename): new NZipArchive;
    }
    NRarArchive rar;
    if (rar.issupport(filename))
    {
        return open? new NRarArchive(filename): new NRarArchive;
    }
    return NULL;
}